home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Developer Helper 1: Phil & Dave's Excellent CD
/
Excellent CD HFS.raw
/
Moof
/
Goodies
/
HyperCard Goodies
/
HyperCard Dev. ToolKit
/
Serial & MacinTalk XCMDs
/
openPort.p
< prev
next >
Wrap
Text File
|
1987-07-15
|
2KB
|
74 lines
{$R-}
(*
openSPort portNumber -- Open the serial port driver.
To compile and link this file using Macintosh Programmer's Workshop,
pascal -w openPort.p
link -m ENTRYPOINT -o HyperCommands -rt XCMD=0 -sn Main=openSPort openPort.p.o "{MPW}"Libraries:interface.o
*)
{$S openSPort } { Segment name must be the same as the command name. }
unit DummyUnit;
interface
uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
procedure EntryPoint(paramPtr: XCmdPtr);
implementation
type
Str31 = String[31];
procedure openSPort(paramPtr: XCmdPtr); forward;
procedure EntryPoint(paramPtr: XCmdPtr);
begin
openSPort(paramPtr);
end;
procedure openSPort(paramPtr: XCmdPtr);
var portNumber: integer;
inPort, outPort: integer;
actualIn, actualOut: integer;
i: integer;
str: Str255;
{$I XCmdGlue.inc}
procedure Fail(errMsg: Str255); { set theResult and quit }
begin
paramPtr^.returnValue := PasToZero(errMsg);
exit(openSPort);
end;
begin
if paramPtr^.paramCount <> 1 then Fail('parameter count is not 1');
ZeroToPas(paramPtr^.params[1]^,str); { First parameter is port number. }
portNumber := StrToNum(str);
if (portNumber < 1) or (portNumber > 2) then Fail('invalid port number');
if portNumber = 1 then
begin
inPort := -6; outPort := -7;
end
else
begin
inPort := -8; outPort := -9;
end;
if (OpenDriver('.AOut',actualOut) <> noErr) or (OpenDriver('.AIn',actualIn) <> noErr) then
Fail('OpenDriver failed');
if (actualOut <> outPort) or (actualIn <> inPort) then Fail('openDriver failed');
end;
end.